package com.mryx.demo.service.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.mryx.demo.mapper.FindMapper;
import com.mryx.demo.pojo.Find;
import com.mryx.demo.pojo.Findclassification;
import com.mryx.demo.service.FindService;
import com.mryx.demo.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 新闻发现业务逻辑层接口实现类
 */
@Service("findService")
public class FindServiceImpl implements FindService {

    @Resource(name = "findMapper")
    private FindMapper mapper;//数据访问层对象

    @Resource
    PageHelper pageHelper;
    @Override
    public List<Findclassification> getAllType() {
        return mapper.getAllType();
    }

    @Override
    public Findclassification getTypeByTid(Integer tid) {
        return mapper.getTypeByTid(tid);
    }

    @Override
    public Integer updType(Findclassification fclass) {
        return mapper.updType(fclass);
    }

    @Override
    public Integer addType(Findclassification fclass) {
        return mapper.addType(fclass);
    }

    @Override
    public List<Find> getAllFindByType(Integer fcid) {
        return mapper.getAllFindByType(fcid);
    }

    @Override
    public Find getFindInfoById(Integer fid) {
        return mapper.getFindInfoById(fid);
    }

    @Override
    public Integer addFind(Find find) {
        return mapper.addFind(find);
    }

    @Override
    public PageBean<Find> getAllFind(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Find> finds = mapper.getAllFind();
        Integer count = mapper.getCount();
        PageBean<Find> pageData = new PageBean<>(currentPage,pageSize, count);
        pageData.setItems(finds);
        return pageData;
    }

    @Override
    public Integer delFind(Integer fid) {
        return mapper.delFind(fid);
    }

    @Override
    public Integer updFind(Find find) {
        return mapper.updFind(find);
    }
}
